package pers.wensheng.patterns.behavioral_pattern.mediator_pattern;

import pers.wensheng.patterns.behavioral_pattern.mediator_pattern.entity.person.HouseOwner;
import pers.wensheng.patterns.behavioral_pattern.mediator_pattern.entity.mediator.MediatorStructure;
import pers.wensheng.patterns.behavioral_pattern.mediator_pattern.entity.person.Tenant;

/**
 * 中介者模式
 * 房子原先的拥有者和要租房子的都属于具体同事类
 */
public class Client {
    public static void main(String[] args) {
        //创建中介者对象
        MediatorStructure mediator = new MediatorStructure();
        //创建租房者对象
        Tenant tenant = new Tenant("李四",mediator);
        //创建房主对象
        HouseOwner houseOwner = new HouseOwner("张三",mediator);


        //中介者要知道具体的房主和租房者
        mediator.setHouseOwner(houseOwner);
        mediator.setTenant(tenant);

        //租房者和中介沟通
        tenant.constact("我要租房子");
        houseOwner.constact("好");

    }
}
